home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume4 / tvx / part06 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  52.0 KB

  1. From: talcott!seismo!gatech!unmvax!wampler (Bruce Wampler)
  2. Subject: tvx: 6 of 10
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 4, Issue 20
  7. Submitted by: gatech!unmvax!wampler (Bruce Wampler)
  8.  
  9. #--------CUT---------CUT---------CUT---------CUT--------#
  10. #########################################################
  11. #  TVX: File 6 of 10                                    #
  12. #                                                       #
  13. # This is a shell archive file.  To extract files:      #
  14. #                                                       #
  15. #    1)    Make a directory (like tvx) for the files.      #
  16. #    2) Write a file, such as "filen.shar", containing  #
  17. #       this archive file into the directory.           #
  18. #    3) Type "sh file.shar".  Do not use csh.           #
  19. #                                                       #
  20. #########################################################
  21. #
  22. #
  23. echo Extracting tvx_edit.c:
  24. sed 's/^X//' >tvx_edit.c <<\SHAR_EOF
  25. X/* ---------------------------------------------------------------------
  26. X    This module contains the main edit routine, which is
  27. Xdifferent for each editor being emulated.  The code that is unique
  28. Xto each emulation is confined to the three .ic files, tvx_lex.c, and
  29. Xthis module.  The remainder of the tvx files are the same for all versions.
  30. X
  31. X
  32. X   This version of TVX Copyright (c) 1986 by Bruce E. Wampler
  33. X
  34. X   Permission is hereby granted for free, unrestricted nonprofit
  35. X   use of this software.  Please feel free to modify, distribute,
  36. X   and share this software as long as you aren't making any money
  37. X   from it.  If you want to use this code in a profit making environment,
  38. X   please contact the author for permission.
  39. X
  40. X--------------------------------------------------------------------- */
  41. X
  42. X#include "tvx_defs.ic"        /* note tv_defs.ic will #include stdio.h */
  43. X#include "tvx_glbl.ic"
  44. X
  45. X  char clower(),cupper();
  46. X
  47. X
  48. X#ifdef TVX_CMDSET        /* works for both tvx_em and tvx0m_em */
  49. X/* =============================>>> EDIT   <<<============================= */
  50. X  edit()
  51. X  { /*    edit - main editing routine */
  52. X
  53. X    SLOW int lexval,lexcnt,succ, lastln, itmp;
  54. X    SLOW int noteloc[10], ni, lex_def;
  55. X    SLOW char lexchr;
  56. X
  57. X    static int ins_set[] =        /* allowable commands for insert */
  58. X      {
  59. X    VINSERT, VOPENLINE, VQUIT, VABORT, VFBEGIN, VGET, VYANK, 0
  60. X      };
  61. X
  62. X    static int jump_set[] =    /* commands to not reset jump memory */
  63. X      {
  64. X    VJUMP, VMEMORY, VHELP, VNOTELOC, VPRINTS, 0
  65. X      };
  66. X    SLOW char fchr;        /* temp char for prefixed commands */
  67. X
  68. X    startm();
  69. X    remark("Reading file...");
  70. X
  71. X    rdpage();            /* read a page into the buffer */
  72. X
  73. X    tvclr();            /* clear the screen */
  74. X
  75. X    if (curlin >= 1)
  76. X    tvtype(curlin,tvlins);    /* type out lines */
  77. X
  78. X    tvxy(1,1);            /* and rehome the cursor */
  79. X    waserr = FALSE;        /* no errors to erase yet */
  80. X
  81. X    if (curlin<1)
  82. X    tverr("Buffer empty");
  83. X#ifdef SCR_BUF
  84. X    ttflush();
  85. X#endif
  86. X
  87. X    lexval = UNKNOWN;        /* so can remember 1st time through */
  88. X    useprint = FALSE;        /* not to printer */
  89. X    succ=TRUE;            /* assume success initially */
  90. X
  91. X    lastln = 1    ;        /* remember where we were */
  92. X    for (ni = 0 ; ni < 10 ; noteloc[ni++] = 1)
  93. X    ;            /* init noteloc */
  94. X    do
  95. X      {
  96. X    oldlex = lexval;        /* remember last command */
  97. X    if (! succ)
  98. X        echof = TRUE;        /* resume echo when error */
  99. X    lex_def = lex(&lexval,&lexcnt,&lexchr,succ);    /* get command input */
  100. X    if (waserr)
  101. X        fixend();
  102. X    waserr=FALSE;
  103. X    succ=TRUE;
  104. X    if (lexval == UNKNOWN)
  105. X      {
  106. X        cmderr(lexchr);
  107. X        succ = FALSE;    /* announce failure to lex */
  108. X      }
  109. X    else
  110. X      {
  111. X        if (curlin < 1)    /* make sure legal command for empty buffer */
  112. X          {
  113. X        if (!inset(lexval,ins_set))
  114. X          {
  115. X            tverrb("Can't, buffer empty. Insert 1st ");
  116. X            succ=FALSE;
  117. X            continue;
  118. X          }
  119. X          }
  120. X        if (!inset(lexval,jump_set))
  121. X        lastln=curlin;        /* let user look at help w/o changing */
  122. X
  123. X        switch (lexval)
  124. X        {
  125. Xcase 1:             /* right */
  126. X        right(lexcnt);
  127. X        break;
  128. Xcase 2:             /* left */
  129. X        right(-lexcnt);
  130. X        break;
  131. Xcase 3:             /* down line */
  132. X        dwnlin(lexcnt);
  133. X        break;
  134. Xcase 4:             /* up line */
  135. X        dwnlin(-lexcnt);
  136. X        break;
  137. Xcase 5:             /* down in column */
  138. X        dwncol(lexcnt);
  139. X        break;
  140. Xcase 6:             /* up in column */
  141. X        dwncol(-lexcnt);
  142. X        break;
  143. Xcase 7:             /* delete last character */
  144. X        succ = delnxt(-lexcnt);
  145. X        break;
  146. Xcase 8:             /* delete next character */
  147. X        succ = delnxt(lexcnt);
  148. X        break;
  149. Xcase 9:             /* insert */
  150. X        succ = insert(lexcnt,lex_def);
  151. X        break;
  152. Xcase 10:            /* kill a line */
  153. X        killin(lexcnt);
  154. X        break;
  155. Xcase 11:            /* kill rest of line */
  156. X        krest();
  157. X        break;
  158. Xcase 12:            /* kill previous part of line */
  159. X        kprev();
  160. X        break;
  161. Xcase 13:            /* move to beginning of line */
  162. X        beglin();
  163. X        break;
  164. Xcase 14:            /* move to end of the line */
  165. X        endlin();
  166. X        break;
  167. Xcase 15:            /* search for a pattern */
  168. X        succ = search(lexcnt,TRUE);
  169. X        break;
  170. Xcase 16:            /* search for next part of a pattern */
  171. X        succ = snext(lexcnt,TRUE);
  172. X        break;
  173. Xcase 17:            /* flip screen */
  174. X        dwnlin(min(lexcnt*tvlins,nxtlin-curlin+1));
  175. X        break;
  176. Xcase 18:            /* goto top of page */
  177. X        toppag();
  178. X        break;
  179. Xcase 19:            /* goto to bottom of page */
  180. X        botpag();
  181. X        break;
  182. Xcase 20:            /* goto real beginning of the file */
  183. X        succ = fbeg();
  184. X        break;
  185. Xcase 21:            /* verify */
  186. X        verify(lexcnt);
  187. X        break;
  188. Xcase 22:            /* open new line */
  189. X        openln(lexcnt);
  190. X#ifdef TVX_EM            /* don't need insert for modeless tvx */
  191. X        succ = insert(1,TRUE); /* go into insert mode, insert mode */
  192. X#endif
  193. X        break;
  194. Xcase 23:            /* delete last thing manipulated */
  195. X        succ = rmvlst();
  196. X        break;
  197. Xcase 24:            /* save lines in move buffer */
  198. X        succ = save(lexcnt,FALSE);
  199. X        break;
  200. Xcase 25:            /* get move buffer */
  201. X        succ = getsav();
  202. X        break;
  203. Xcase 26:            /* read in next page of file */
  204. X        wtpage(lexcnt);    /* write out the current page */
  205. X        succ = rdpage();    /* read in the next */
  206. X        tvclr();
  207. X        if (succ || lexcnt < 0)
  208. X        verify(1);
  209. X        break;
  210. Xcase 27:            /* append external file to save buffer */
  211. X        succ = addfil(lexcnt);
  212. X        break;
  213. Xcase 28:            /* quit */
  214. X        tvclr();
  215. X        remark("Exit");
  216. X        goto lquit;
  217. Xcase 29:            /* search again */
  218. X        succ = search(lexcnt,FALSE); /* FALSE => don't read search string */
  219. X        break;
  220. Xcase 30:            /* execute repeat buffer again */
  221. X        if (lexcnt != 1)
  222. X        echof=FALSE;    /* turn off echo */
  223. X        rptcnt[rptuse] = lexcnt > 0 ? lexcnt : (-lexcnt);
  224. X        break;
  225. Xcase 31:            /* print memory status, etc. */
  226. X        memory();
  227. X        break;
  228. Xcase 32:            /* change a parameter */
  229. X        if (!grptch(&fchr))
  230. X          {
  231. X        succ = FALSE;
  232. X        break;
  233. X          }
  234. X        setpar(lexcnt,fchr);
  235. X        break;
  236. Xcase 33:            /* remove last and enter insert mode */
  237. X        if ((succ = rmvlst()))
  238. X        succ = insert(1,TRUE);
  239. X        break;
  240. Xcase 34:            /* unkill last line killed */
  241. X        succ = unkill();
  242. X        break;
  243. Xcase 35:            /* jump over a word */
  244. X        wordr(lexcnt);
  245. X        break;
  246. Xcase 36:            /* neg jump over word */
  247. X        wordr(-lexcnt);
  248. X        break;
  249. Xcase 37:            /* append to save buffer */
  250. X        succ = save(lexcnt,TRUE);
  251. X        break;
  252. Xcase 38:            /* print screen */
  253. X        scrprint();
  254. X        break;
  255. Xcase 39:            /* show repeat buffer + help*/
  256. X        shoset();
  257. X        break;
  258. Xcase 40:            /* flip screen half page */
  259. X        dwnlin( min((lexcnt*tvlins)/2 , nxtlin-curlin+1) );
  260. X        break;
  261. Xcase 41:            /* abort */
  262. X        abort();
  263. X        break;
  264. Xcase 42:            /* change characters */
  265. X        if ((succ = delnxt(lexcnt)))
  266. X        succ = insert(1,TRUE);
  267. X        break;
  268. Xcase 43:            /* jump back to last location */
  269. X        itmp = curlin;
  270. X        curlin = lastln;
  271. X        curchr = *(lines+curlin)+1;    /* point to the current character */
  272. X        verify(1);
  273. X        lastln = itmp;
  274. X        break;
  275. Xcase 44:            /* tidy up screen */
  276. X        succ = neaten(lexcnt);
  277. X        break;
  278. Xcase 45:            /* save current location */
  279. X        if (lexcnt < 1 || lexcnt > 9)
  280. X        lexcnt = 0;
  281. X        noteloc[lexcnt] = curlin;
  282. X        break;
  283. Xcase 46:            /* return to noted location */
  284. X        itmp = curlin;
  285. X        if (lexcnt < 1 || lexcnt > 9)
  286. X        lexcnt = 0;
  287. X        if (noteloc[lexcnt] >= nxtlin)
  288. X          {
  289. X        tverrb("Line no longer there ");
  290. X        noteloc[lexcnt] = curlin;
  291. X          }
  292. X        else
  293. X          {
  294. X        curlin = noteloc[lexcnt];
  295. X        curchr = *(lines+curlin)+1; /* point to the current character */
  296. X        verify(1);
  297. X        lastln = itmp;
  298. X          }
  299. X        break;
  300. X
  301. Xcase 47:
  302. X        opsystem();        /* call operating system */
  303. X        break;
  304. X
  305. Xcase 48:
  306. X        if (lex_def)        /* default 1 passed */
  307. X        lexcnt = rptuse + 1;    /* use current repeat loop */
  308. X        succ = edit_rpt(lexcnt);    /* edit repeat buffer */
  309. X        break;
  310. X
  311. Xcase 49:
  312. X        succ = store_rpt(lexcnt);    /* store repeat buffer */
  313. X        break;
  314. X
  315. Xcase 50:
  316. X        succ = exec_rpt(lexcnt);    /* execute repeat buffer */
  317. X        break;
  318. X
  319. Xcase 51:
  320. X        succ = ins_pat(lexcnt);
  321. X        break;
  322. Xcase 52:
  323. X        succ = user_1(lexcnt);    /* user function 1 */
  324. X        break;
  325. X
  326. Xcase 53:
  327. X        succ = user_2(lexcnt);    /* user function 2 */
  328. X        break;
  329. Xcase 54:                /* '~': change case */
  330. X        foldcase(lexcnt);
  331. X        break;
  332. X        }              /* end of switch */
  333. X        continue;        /* next iteration of do loop */
  334. X      } /* end of else */
  335. X#ifdef SCR_BUF
  336. X    ttflush();
  337. X#endif
  338. X      } /* end of do loop */
  339. X    while (1);
  340. X
  341. Xlquit:
  342. X    for ( wtpage(1) ; rdpage() ; wtpage(1) )    /* write whole file */
  343. X    ;
  344. X    tvclr();
  345. X  }
  346. X#endif
  347. X
  348. X#ifdef VI_EM            /* vi emulation */
  349. X/* =============================>>> EDIT   <<<============================= */
  350. X  edit()
  351. X  { /*    edit - main editing routine */
  352. X
  353. X    SLOW int lexval,lexcnt,succ, lastln, itmp;
  354. X    SLOW int noteloc[10], ni, lex_def;
  355. X    SLOW char lexchr;
  356. X
  357. X    static int ins_set[] =    /* MUCH more limited than tvx */
  358. X      {
  359. X    VINSERT, VENDZ, VTVX, VNOOP, 0
  360. X      };
  361. X
  362. X    static int jump_set[] =    /* commands to not reset jump memory */
  363. X      {
  364. X    VTVX, VMEMORY, VHELP, VNOTELOC, VNOOP, 0
  365. X      };
  366. X    SLOW char fchr;        /* temp char for prefixed commands */
  367. X    static int dir_up = FALSE;    /* search down by default */
  368. X
  369. X    startm();
  370. X    remark("Reading file...");
  371. X
  372. X    rdpage();            /* read a page into the buffer */
  373. X
  374. X    tvclr();            /* clear the screen */
  375. X
  376. X    if (curlin >= 1)
  377. X    tvtype(curlin,tvlins);    /* type out lines */
  378. X
  379. X    tvxy(1,1);            /* and rehome the cursor */
  380. X    waserr = FALSE;        /* no errors to erase yet */
  381. X
  382. X    if (curlin<1)
  383. X    tverr("Buffer empty");
  384. X#ifdef SCR_BUF
  385. X    ttflush();
  386. X#endif
  387. X
  388. X    lexval = UNKNOWN;        /* so can remember 1st time through */
  389. X    useprint = FALSE;        /* not to printer */
  390. X    succ=TRUE;            /* assume success initially */
  391. X
  392. X    lastln = 1    ;        /* remember where we were */
  393. X    for (ni = 0 ; ni < 10 ; noteloc[ni++] = 1)
  394. X    ;            /* init noteloc */
  395. X    do
  396. X      {
  397. X    oldlex = lexval;        /* remember last command */
  398. X    if (! succ)
  399. X        echof = TRUE;        /* resume echo when error */
  400. X    lex_def = lex(&lexval,&lexcnt,&lexchr,succ);    /* get command input */
  401. X    if (waserr)
  402. X        fixend();
  403. X    waserr=FALSE;
  404. X    succ=TRUE;
  405. X    if (lexval == UNKNOWN)
  406. X      {
  407. X        cmderr(lexchr);
  408. X        succ = FALSE;    /* announce failure to lex */
  409. X      }
  410. X    else
  411. X      {
  412. X        if (curlin < 1)    /* make sure legal command for empty buffer */
  413. X          {
  414. X        if (!inset(lexval,ins_set))
  415. X          {
  416. X            tverrb("Can't, buffer empty. Insert 1st ");
  417. X            succ=FALSE;
  418. X            continue;
  419. X          }
  420. X          }
  421. X        if (!inset(lexval,jump_set))
  422. X        lastln=curlin;        /* let user look at help w/o changing */
  423. X
  424. X/* these all started out in order, but... */
  425. X        switch (lexval)
  426. X        {
  427. Xcase 1:             /* ^B: screen up */
  428. X        dwnlin(min(-lexcnt*tvlins,nxtlin-curlin+1));
  429. X        break;
  430. Xcase 2:             /* ^D: half screen */
  431. X        dwnlin( min((lexcnt*tvlins)/2 , nxtlin-curlin+1) );
  432. X        break;
  433. Xcase 3:             /* ^F: screen down */
  434. X        dwnlin(min(lexcnt*tvlins,nxtlin-curlin+1));
  435. X        break;
  436. Xcase 4:             /* ^G: memory status */
  437. X        memory();
  438. X        break;
  439. Xcase 5:             /* ^H: left (must be here to avoid
  440. X                    conflict with normal char del */
  441. X        right(-lexcnt);
  442. X        break;
  443. Xcase 6:             /* ^L: verify screen */
  444. X        verify(lexcnt);
  445. X        break;
  446. Xcase 7:             /* '=': help */
  447. X        shoset();
  448. X        break;
  449. Xcase 8:             /* '!' - tidy */
  450. X        succ = neaten(lexcnt);
  451. X        break;
  452. Xcase 9:             /* '#': execute macro n times */
  453. X        succ = exec_rpt(lexcnt);    /* execute repeat buffer */
  454. X        break;
  455. Xcase 10:            /* '$': end of current line */
  456. X        endlin();
  457. X        break;
  458. Xcase 11:            /* '*': insert last found pattern */
  459. X        succ = ins_pat(lexcnt);
  460. X        break;
  461. Xcase 12:            /* '/': search down */
  462. X        dir_up = FALSE;
  463. X        succ = search(1,TRUE);    /* searching down*/
  464. X        break;
  465. Xcase 13:            /* ':': set parameter, just like tvx */
  466. X        tverrb("Use ZZ to exit ");
  467. X        break;
  468. Xcase 14:            /* 'J': join lines */
  469. X        endlin();
  470. X        delnxt(lexcnt);
  471. X        succ = insert((int) ' ',FALSE);
  472. X        break;
  473. Xcase 15:            /* '?': find upwards */
  474. X        dir_up = TRUE;
  475. X        succ = search(-1,TRUE);
  476. X        break;
  477. Xcase 16:            /* '@': execute current repeat loop */
  478. X        if (lexcnt != 1)
  479. X        echof=FALSE;    /* turn off echo */
  480. X        rptcnt[rptuse] = lexcnt > 0 ? lexcnt : (-lexcnt);
  481. X        break;
  482. Xcase 17:            /* 'A': append to end of line {.i} */
  483. X        endlin();
  484. X        succ = insert(1,TRUE); /* go into insert mode, insert mode */
  485. X        break;
  486. Xcase 18:            /* 'C': changes rest of line {"i } */
  487. X        krest();        /* kill rest of line */
  488. X        succ = insert(1,TRUE); /* enter insert mode */
  489. X        break;
  490. Xcase 19:            /* 'D': delete rest of the line {"} */
  491. X        krest();        /* kill rest of line */
  492. X        break;
  493. Xcase 20:            /* 'G': goes to line number n, or
  494. X                    end of buffer if no n */
  495. X        if (lex_def)    /* no n supplied */
  496. X        botpag();
  497. X        else
  498. X          {
  499. X        toppag();    /* go to top of file */
  500. X        dwnlin(lexcnt - 1);    /* go to that line */
  501. X          }
  502. X        break;
  503. Xcase 21:            /* 'H': Beginning of buffer */
  504. X        toppag();        /* go to top of buffer */
  505. X        break;
  506. X
  507. Xcase 22:            /* 'I': inserts a beginning of line */
  508. X        beglin();
  509. X        succ = insert(1,TRUE); /* go into insert mode */
  510. X        break;
  511. Xcase 23:            /* 'J': like vi j - down in column */
  512. X        dwncol(lexcnt);
  513. X        break;
  514. Xcase 24:            /* 'K': like vi k - up in column */
  515. X        dwncol(-lexcnt);
  516. X        break;
  517. Xcase 25:            /* 'L': bottom line of file */
  518. X        botpag();
  519. X        beglin();
  520. X        break;
  521. Xcase 26:            /* 'M': return to marked location */
  522. X        itmp = curlin;
  523. X        if (lexcnt < 1 || lexcnt > 9)
  524. X        lexcnt = 0;
  525. X        if (noteloc[lexcnt] >= nxtlin)
  526. X          {
  527. X        tverrb("Line no longer there ");
  528. X        noteloc[lexcnt] = curlin;
  529. X          }
  530. X        else
  531. X          {
  532. X        curlin = noteloc[lexcnt];
  533. X        curchr = *(lines+curlin)+1; /* point to the current character */
  534. X        verify(1);
  535. X        lastln = itmp;
  536. X          }
  537. X        break;
  538. Xcase 27:            /* 'N': reverse find again */
  539. X        succ = search((dir_up ? 1 : -1),FALSE);
  540. X             /* FALSE => don't read search string */
  541. X        break;
  542. Xcase 28:            /* 'O': open a line above current line */
  543. X        beglin();
  544. X        openln(lexcnt);
  545. X        succ = insert(1,TRUE); /* go into insert mode, insert mode */
  546. X        break;
  547. Xcase 29:            /* 'P': put save buffer above current line */
  548. X        beglin();
  549. X        succ = getsav();
  550. X        break;
  551. Xcase 30:            /* 'T': tvx commands */
  552. X        if (!grptch(&fchr))
  553. X          {
  554. X        succ = FALSE;
  555. X        break;
  556. X          }
  557. X        fchr = clower(fchr);    /* lower case */
  558. X        if (curlin < 1)    /* make sure legal command for empty buffer */
  559. X          {
  560. X        if ( fchr != 'b')
  561. X          {
  562. X            tverrb("Can't, buffer empty. Insert 1st ");
  563. X            succ=FALSE;
  564. X            break;
  565. X          }
  566. X          }
  567. X        switch (fchr)
  568. X        {
  569. X        case ':':            /* set parameter */
  570. X        if (!grptch(&fchr))
  571. X          {
  572. X            succ = FALSE;
  573. X            break;
  574. X          }
  575. X        setpar(lexcnt,fchr);
  576. X        break;
  577. X        case '!':
  578. X        opsystem();        /* call operating system */
  579. X        break;
  580. X        case 'b':            /* goto real beginning of the file */
  581. X        succ = fbeg();
  582. X        break;
  583. X        case 'e':            /* edit repeat buffer */
  584. X        if (lex_def)        /* default 1 passed */
  585. X            lexcnt = rptuse + 1;    /* use current repeat loop */
  586. X        succ = edit_rpt(lexcnt);    /* edit repeat buffer */
  587. X        break;
  588. X        case 'j':            /* jump back to last location */
  589. X        itmp = curlin;
  590. X        curlin = lastln;
  591. X        curchr = *(lines+curlin)+1; /* point to the current character */
  592. X        verify(1);
  593. X        lastln = itmp;
  594. X        break;
  595. X        case 'p':        /* put external file from save buffer */
  596. X        succ = addfil(-1);
  597. X        break;
  598. X        case 'r':            /* restore repeat buffer */
  599. X        succ = store_rpt(lexcnt);    /* store repeat buffer */
  600. X        break;
  601. X        case 's':            /* print screen */
  602. X        scrprint();
  603. X        break;
  604. X        case 'u':            /* "undo" */
  605. X        succ = unkill();
  606. X        break;
  607. X        case 'w':            /* read in next page of file */
  608. X        wtpage(lexcnt);    /* write out the current page */
  609. X        succ = rdpage();    /* read in the next */
  610. X        tvclr();
  611. X        if (succ || lexcnt < 0)
  612. X            verify(1);
  613. X        break;
  614. X        case 'y':        /* yank external file to save buffer */
  615. X        succ = addfil(1);
  616. X        break;
  617. X        case '/':        /* search across buffers */
  618. X        succ = snext(1,TRUE);
  619. X        break;
  620. X        case '(':        /* user 1 */
  621. X        succ = user_1(lexcnt);    /* user function 1 */
  622. X        break;
  623. X        default:
  624. X        tverrb("Use !,b,e,j,p,r,s,u,w,y, or / with q ");
  625. X        break;
  626. X        }
  627. X        break;
  628. Xcase 31:            /* 'X': delete character before cursor */
  629. X        succ = delnxt(-lexcnt);
  630. X        break;
  631. Xcase 32:            /* 'Y': append to save buffer */
  632. X        succ = save(lexcnt,TRUE);
  633. X        break;
  634. Xcase 33:            /* 'Z': exit (ZZ: normal, ZA: abort) */
  635. X        if (!grptch(&fchr))
  636. X          {
  637. X        succ = FALSE;
  638. X        break;
  639. X          }
  640. X        switch (clower(fchr))
  641. X        {
  642. X        case 'z':        /* normal exit */
  643. X        tvclr();
  644. X        remark("Exit");
  645. X        goto lquit;
  646. X        case 'a':        /* abort or terminate exit */
  647. X        abort();
  648. X        break;
  649. X        case 27:        /* escape is no op */
  650. X        break;
  651. X        default:
  652. X        tverrb("Use Z or A with Z");
  653. X        break;
  654. X        }
  655. X        break;
  656. Xcase 34:            /* '^': beginning of line */
  657. X        beglin();
  658. X        break;
  659. Xcase 35:            /* 'a': append text */
  660. X        right(1);
  661. X        succ = insert(lexcnt,lex_def);
  662. X        break;
  663. Xcase 36:            /* 'b': word left */
  664. X        wordr(-lexcnt);
  665. X        break;
  666. Xcase 37:            /* 'c': change something */
  667. X        if (!grptch(&fchr))
  668. X          {
  669. X        succ = FALSE;
  670. X        break;
  671. X          }
  672. X        switch (clower(fchr))
  673. X        {
  674. X        case 'c':        /* change line */
  675. X        killin(lexcnt);    /* remove the line */
  676. X        openln(1);
  677. X        succ = insert(1,TRUE); /* go into insert mode */
  678. X        break;
  679. X        case ' ':        /* change one character */
  680. X        delnxt(lexcnt);
  681. X        succ = insert(1,TRUE); /* go into insert mode */
  682. X        break;
  683. X        case '^':        /* to beginning of line */
  684. X        kprev();
  685. X        succ = insert(1,TRUE); /* go into insert mode */
  686. X        break;
  687. X        case '$':        /* to beginning of line */
  688. X        krest();
  689. X        succ = insert(1,TRUE); /* go into insert mode */
  690. X        break;
  691. X        case '/':        /* delete last thing, enter insert */
  692. X        if ((succ = rmvlst()))
  693. X            succ = insert(1,TRUE);
  694. X        break;
  695. X        case 27:        /* escape is no op */
  696. X        break;
  697. X        default:
  698. X        tverrb("Use c,<sp>,^,$, or / with c ");
  699. X        break;
  700. X        }
  701. X        break;
  702. Xcase 38:            /* 'd': delete d, <sp>, ^, or $ */
  703. X        if (!grptch(&fchr))
  704. X          {
  705. X        succ = FALSE;
  706. X        break;
  707. X          }
  708. X        switch (clower(fchr))
  709. X        {
  710. X        case 'd':        /* delete line */
  711. X        killin(lexcnt);    /* remove the line */
  712. X        break;
  713. X        case ' ':        /* delete character */
  714. X        delnxt(lexcnt);
  715. X        break;
  716. X        case '0':
  717. X        case '^':        /* to beginning of line */
  718. X        kprev();
  719. X        break;
  720. X        case '$':        /* to beginning of line */
  721. X        krest();
  722. X        break;
  723. X        case '/':        /* delete last thing */
  724. X        succ = rmvlst();
  725. X        break;
  726. X        case 27:        /* escape is no op */
  727. X        break;
  728. X        default:
  729. X        tverrb("Use d,<sp>,^,$, or / with d ");
  730. X        break;
  731. X        }
  732. X        break;
  733. Xcase 39:            /* ^U: half screen up */
  734. X        dwnlin( min((-lexcnt*tvlins)/2 , nxtlin-curlin+1) );
  735. X        break;
  736. Xcase 40:            /* 'i': insert */
  737. X        succ = insert(1,lex_def);
  738. X        break;
  739. Xcase 41:            /* 'j': down to line beginning */
  740. X        dwnlin(lexcnt);
  741. X        break;
  742. Xcase 42:            /* 'k': up to line beginning */
  743. X        dwnlin(-lexcnt);
  744. X        break;
  745. Xcase 43:            /* 'l': right */
  746. X        right(lexcnt);
  747. X        break;
  748. Xcase 44:            /* 'm': mark location n */
  749. X        if (lexcnt < 1 || lexcnt > 9)
  750. X        lexcnt = 0;
  751. X        noteloc[lexcnt] = curlin;
  752. X        break;
  753. Xcase 45:            /* 'n': find next (in last direction) */
  754. X        succ = search((dir_up ? -1 : 1),FALSE);
  755. X        break;
  756. Xcase 46:            /* 'o': open following line {do} */
  757. X        dwnlin(1);
  758. X        openln(lexcnt);
  759. X        succ = insert(1,TRUE); /* go into insert mode */
  760. X        break;
  761. Xcase 47:            /* 'p': put save buffer after cur line */
  762. X        dwnlin(1);
  763. X        succ = getsav();
  764. X        break;
  765. Xcase 48:            /* 'r': replace next char */
  766. X        if (!grptch(&fchr))
  767. X          {
  768. X        succ = FALSE;
  769. X        break;
  770. X          }
  771. X        delnxt(lexcnt);        /* delete count character */
  772. X        succ = insert((int)fchr,FALSE);
  773. X#ifndef VI_MODS
  774. X        right(-1);            /* and back over char replaced */
  775. X#endif
  776. X        break;
  777. Xcase 49:                /* 's': substitute */
  778. X        if ((succ = delnxt(lexcnt)))
  779. X        succ = insert(1,TRUE);
  780. X        break;
  781. Xcase 50:                /* ESC: no operation */
  782. X        break;
  783. Xcase 51:                /* 'w': advance word */
  784. X        wordr(lexcnt);
  785. X        break;
  786. Xcase 52:                /* 'x': delete char */
  787. X        succ = delnxt(lexcnt);
  788. X        break;
  789. Xcase 53:                /* 'y': yank to save buffer */
  790. X        succ = save(lexcnt,FALSE);
  791. X        break;
  792. Xcase 54:                /* '~': change case */
  793. X        foldcase(lexcnt);
  794. X        break;
  795. X        }              /* end of switch */
  796. X        continue;        /* next iteration of do loop */
  797. X      } /* end of else */
  798. X#ifdef SCR_BUF
  799. X    ttflush();
  800. X#endif
  801. X      } /* end of do loop */
  802. X    while (1);
  803. X
  804. Xlquit:
  805. X    for ( wtpage(1) ; rdpage() ; wtpage(1) )    /* write whole file */
  806. X    ;
  807. X    tvclr();
  808. X  }
  809. X#endif
  810. X
  811. X#ifdef EMAX_EM        /* emacs modeless editor emulation */
  812. X/* =============================>>> EDIT   <<<============================= */
  813. X  edit()
  814. X  { /*    edit - main editing routine */
  815. X
  816. X    SLOW int lexval,lexcnt,succ, lastln, itmp;
  817. X    SLOW int noteloc[10], ni, lex_def;
  818. X    SLOW char lexchr;
  819. X
  820. X    static int ins_set[] =    /* MUCH more limited than tvx */
  821. X      {
  822. X    VQUIT, VTVX, VNOOP, VEXTEND, VOPENLINE, VGET, 0
  823. X      };
  824. X
  825. X    static int jump_set[] =    /* commands to not reset jump memory */
  826. X      {
  827. X    VTVX, VHELP, VNOOP, 0
  828. X      };
  829. X
  830. X    static int c_jump_set[] =    /* jump set for ^C */
  831. X      {
  832. X    7, 10, 13, 'l', 0
  833. X      };
  834. X
  835. X    SLOW char fchr;        /* temp char for prefixed commands */
  836. X
  837. X    startm();
  838. X    remark("Reading file...");
  839. X
  840. X    rdpage();            /* read a page into the buffer */
  841. X
  842. X    tvclr();            /* clear the screen */
  843. X
  844. X    if (curlin >= 1)
  845. X    tvtype(curlin,tvlins);    /* type out lines */
  846. X
  847. X    tvxy(1,1);            /* and rehome the cursor */
  848. X    waserr = FALSE;        /* no errors to erase yet */
  849. X
  850. X    if (curlin<1)
  851. X    tverr("Buffer empty");
  852. X#ifdef SCR_BUF
  853. X    ttflush();
  854. X#endif
  855. X
  856. X    lexval = UNKNOWN;        /* so can remember 1st time through */
  857. X    useprint = FALSE;        /* not to printer */
  858. X    succ=TRUE;            /* assume success initially */
  859. X
  860. X    lastln = 1 ;    /* remember where we were */
  861. X    for (ni = 0 ; ni < 10 ; noteloc[ni++] = 1)
  862. X    ;            /* init noteloc */
  863. X    do
  864. X      {
  865. X    oldlex = lexval;        /* remember last command */
  866. X    if (! succ)
  867. X        echof = TRUE;        /* resume echo when error */
  868. X    lex_def = lex(&lexval,&lexcnt,&lexchr,succ);    /* get command input */
  869. X    if (waserr)
  870. X        fixend();
  871. X    waserr=FALSE;
  872. X    succ=TRUE;
  873. X    if (lexval == UNKNOWN)
  874. X      {
  875. X        cmderr(lexchr);
  876. X        succ = FALSE;    /* announce failure to lex */
  877. X      }
  878. X    else
  879. X      {
  880. X        if (curlin < 1)    /* make sure legal command for empty buffer */
  881. X          {
  882. X        if (!inset(lexval,ins_set))
  883. X          {
  884. X            tverrb("Can't, buffer empty. Insert 1st ");
  885. X            succ=FALSE;
  886. X            continue;
  887. X          }
  888. X          }
  889. X        if (!inset(lexval,jump_set))
  890. X        lastln = curlin;    /* let user look at help w/o changing */
  891. X
  892. X        switch (lexval)
  893. X        {
  894. Xcase 1:             /* ^A: Cursor to start of line */
  895. X        beglin();
  896. X        break;
  897. Xcase 2:             /* ^B: left */
  898. X        right(-lexcnt);
  899. X        break;
  900. Xcase 3:             /* ^C: Command (tvx) */
  901. X        if (!grptch(&fchr))
  902. X          {
  903. X        succ = FALSE;
  904. X        break;
  905. X          }
  906. X        fchr = clower(fchr);    /* lower case */
  907. X        if (curlin < 1)    /* make sure legal command for empty buffer */
  908. X          {
  909. X        if ( fchr != 2 && fchr != 'r')
  910. X          {
  911. X            tverrb("Can't, buffer empty. Insert 1st ");
  912. X            succ=FALSE;
  913. X            break;
  914. X          }
  915. X          }
  916. X        if (!inset((int)fchr,c_jump_set))
  917. X        lastln = curlin;    /* reset jump loc if not special */
  918. X
  919. X        switch (fchr)
  920. X        {
  921. X        case 1:            /* ^A: append to save buffer */
  922. X        lexval = VSAPPEND;
  923. X        succ = save(lexcnt,TRUE);
  924. X        break;
  925. X        case 2:            /* ^B: goto real begin of the file */
  926. X        succ = fbeg();
  927. X        break;
  928. X        case 5:            /* ^E: edit repeat buffer */
  929. X        if (lex_def)        /* default 1 passed */
  930. X            lexcnt = rptuse + 1;    /* use current repeat loop */
  931. X        succ = edit_rpt(lexcnt);    /* edit repeat buffer */
  932. X        break;
  933. X        case 6:            /* ^F: fill (tidy) */
  934. X        succ = neaten(lexcnt);
  935. X        break;
  936. X        case 7:            /* ^G: no op */
  937. X        break;
  938. X        case 8:            /* ^H: half screen down */
  939. X        dwnlin( min((lexcnt*tvlins)/2 , nxtlin-curlin+1) );
  940. X        break;
  941. X        case 10:            /* ^J: jump back to last location */
  942. X        itmp = curlin;
  943. X        curlin = lastln;
  944. X        curchr = *(lines+curlin)+1;    /* point to the current char */
  945. X        verify(1);
  946. X        lastln = itmp;
  947. X        break;
  948. X        case 11:            /* ^K: kill last thing */
  949. X        succ = rmvlst();
  950. X        break;
  951. X        case 13:            /* ^M: Mark current loc */
  952. X        if (lexcnt < 1 || lexcnt > 9)
  953. X            lexcnt = 0;
  954. X        noteloc[lexcnt] = curlin;
  955. X        break;
  956. X        case 14:            /* ^N: move to next line */
  957. X        dwnlin(lexcnt);
  958. X        break;
  959. X        case 16:            /* ^P: beginning of prev line */
  960. X        dwnlin(-lexcnt);
  961. X        break;
  962. X        case 18:            /* ^R: restore repeat buffer */
  963. X        succ = store_rpt(lexcnt);    /* store repeat buffer */
  964. X        break;
  965. X        case 23:            /* ^W: write buffer */
  966. X        wtpage(lexcnt);    /* write out the current page */
  967. X        succ = rdpage();    /* read in the next */
  968. X        tvclr();
  969. X        if (succ || lexcnt < 0)
  970. X            verify(1);
  971. X        break;
  972. X        case '(':        /* user 1 */
  973. X        succ = user_1(lexcnt);    /* user function 1 */
  974. X        break;
  975. X        case '~':            /* ~: change case */
  976. X        foldcase(lexcnt);
  977. X        break;
  978. X        case '*':            /* * insert found pattern */
  979. X        succ = ins_pat(lexcnt);
  980. X        break;
  981. X        case ';':            /* ;: search again */
  982. X        lexval = VSAGAIN;
  983. X        succ = search(1,FALSE);
  984. X        break;
  985. X        case 'g':            /* goto line number n */
  986. X        toppag();    /* go to top of file */
  987. X        dwnlin(lexcnt - 1);    /* go to that line */
  988. X        break;
  989. X        case 'h':            /* H: half screen up */
  990. X        dwnlin( min((-lexcnt*tvlins)/2 , nxtlin-curlin+1) );
  991. X        break;
  992. X        case 'i':
  993. X        succ = insert(lexcnt,lex_def);
  994. X        break;
  995. X        case 'l':            /* print screen */
  996. X        scrprint();
  997. X        break;
  998. X        case 'm':            /* m: return to marked loc */
  999. X        itmp = curlin;
  1000. X        if (lexcnt < 1 || lexcnt > 9)
  1001. X            lexcnt = 0;
  1002. X        if (noteloc[lexcnt] >= nxtlin)
  1003. X          {
  1004. X            tverrb("Line no longer there ");
  1005. X            noteloc[lexcnt] = curlin;
  1006. X          }
  1007. X        else
  1008. X          {
  1009. X            curlin = noteloc[lexcnt];
  1010. X            curchr = *(lines+curlin)+1; /* point to the current char */
  1011. X            verify(1);
  1012. X            lastln = itmp;
  1013. X          }
  1014. X        break;
  1015. X        case 'p':            /* p: put line ins save buffer */
  1016. X        lexval = VSAVE;
  1017. X        succ = save(lexcnt,FALSE);
  1018. X        break;
  1019. X        case 'r':        /* read external file to save buffer */
  1020. X        succ = addfil(1);
  1021. X        break;
  1022. X        case 's':        /* search across buffers */
  1023. X        lexval = VNEXT;
  1024. X        succ = snext(1,TRUE);
  1025. X        break;
  1026. X        case 'u':            /* "undo" */
  1027. X        succ = unkill();
  1028. X        break;
  1029. X        case 'v':            /* v: set value */
  1030. X         if (!grptch(&fchr))
  1031. X          {
  1032. X            succ = FALSE;
  1033. X            break;
  1034. X          }
  1035. X        setpar(lexcnt,fchr);
  1036. X        break;
  1037. X        case 'w':        /* write save buffer to file*/
  1038. X        succ = addfil(-1);
  1039. X        break;
  1040. X        default:
  1041. X        tverrb("Not valid command for ^C prefix ");
  1042. X        break;
  1043. X        }
  1044. X        break;
  1045. Xcase 4:             /* ^D: Delete next char */
  1046. X        succ = delnxt(lexcnt);
  1047. X        break;
  1048. Xcase 5:             /* ^E: End of line */
  1049. X        endlin();
  1050. X        break;
  1051. Xcase 6:             /* ^F: right (forward) */
  1052. X        right(lexcnt);
  1053. X        break;
  1054. Xcase 7:             /* ^G: noop */
  1055. X        break;
  1056. Xcase 8:             /* ^H: delete backwards */
  1057. X        succ = delnxt(-lexcnt);
  1058. X        break;
  1059. Xcase 9:             /* ^K: kill line */
  1060. X        if (lex_def)    /* no n supplied */
  1061. X          {
  1062. X        if (*(buff+curchr) == ENDLINE)    /* + new line if there */
  1063. X            delnxt(1);
  1064. X        else
  1065. X            krest();    /* delete rest of the line, or newline */
  1066. X          }
  1067. X        else if (lexcnt == 0)    /* to beginning if 0 */
  1068. X        kprev();
  1069. X        else
  1070. X        killin(lexcnt);
  1071. X        break;
  1072. Xcase 10:            /* ^L: verify */
  1073. X        verify(1);
  1074. X        break;
  1075. Xcase 11:            /* ^N: next line (down in col) */
  1076. X        dwncol(lexcnt);
  1077. X        break;
  1078. Xcase 12:            /* ^O: open line */
  1079. X        openln(lexcnt);
  1080. X        break;
  1081. Xcase 13:            /* ^P: previous line (up in col) */
  1082. X        dwncol(-lexcnt);
  1083. X        break;
  1084. Xcase 14:            /* ^R: reverse search */
  1085. X        succ = search(-1,TRUE);
  1086. X        break;
  1087. Xcase 15:            /* ^S: normal search */
  1088. X        succ = search(1,TRUE);
  1089. X        break;
  1090. Xcase 16:            /* ^V: forward pages */
  1091. X        dwnlin(min(lexcnt*tvlins,nxtlin-curlin+1));
  1092. X        break;
  1093. Xcase 17:            /* ^X: extended command */
  1094. X        if (!grptch(&fchr))
  1095. X          {
  1096. X        succ = FALSE;
  1097. X        break;
  1098. X          }
  1099. X        fchr = clower(fchr);    /* lower case */
  1100. X        if (curlin < 1)    /* make sure legal command for empty buffer */
  1101. X          {
  1102. X        if ( fchr != 3)
  1103. X          {
  1104. X            tverrb("Can't, buffer empty. Insert 1st ");
  1105. X            succ=FALSE;
  1106. X            break;
  1107. X          }
  1108. X          }
  1109. X        switch (fchr)
  1110. X        {
  1111. X        case 2:
  1112. X        memory();
  1113. X        break;
  1114. X        case 3:            /* ^C: abort */
  1115. X        abort();
  1116. X        break;
  1117. X        case 'e':            /* execute repeat loop */
  1118. X        if (lexcnt != 1)
  1119. X            echof=FALSE;    /* turn off echo */
  1120. X        rptcnt[rptuse] = lexcnt > 0 ? lexcnt : (-lexcnt);
  1121. X        break;
  1122. X        default:
  1123. X        tverrb("Not valid command for ^X prefix ");
  1124. X        break;
  1125. X        }
  1126. X    
  1127. X        break;
  1128. Xcase 18:            /* ^Y: Yank back save buffer */
  1129. X        succ = getsav();
  1130. X        break;
  1131. Xcase 19:            /* ^Z: save and exit */
  1132. X        tvclr();
  1133. X        remark("Save and exit");
  1134. X        goto lquit;
  1135. Xcase 20:            /* !: call os */
  1136. X        opsystem();        /* call operating system */
  1137. X        break;
  1138. X
  1139. X/*    these have been prefixed by escape */
  1140. Xcase 21:            /* #: execute repeat loop again */
  1141. X        succ = exec_rpt(lexcnt);    /* execute repeat buffer */
  1142. X        break;
  1143. Xcase 22:            /* >: end of buffer */
  1144. X        botpag();
  1145. X        break;
  1146. Xcase 23:            /* <: top of buffer */
  1147. X        toppag();
  1148. X        break;
  1149. Xcase 24:            /* b: backward words */
  1150. X        wordr(-lexcnt);
  1151. X        break;
  1152. Xcase 25:            /* f: forward words */
  1153. X        wordr(lexcnt);
  1154. X        break;
  1155. Xcase 26:            /* v: backward pages */
  1156. X        dwnlin(min(-lexcnt*tvlins,nxtlin-curlin+1));
  1157. X        break;
  1158. Xcase 27:            /* ?: help */
  1159. X        shoset();
  1160. X        break;
  1161. X        }              /* end of switch */
  1162. X        continue;        /* next iteration of do loop */
  1163. X      } /* end of else */
  1164. X#ifdef SCR_BUF
  1165. X    ttflush();
  1166. X#endif
  1167. X      } /* end of do loop */
  1168. X    while (1);
  1169. X
  1170. Xlquit:
  1171. X    for ( wtpage(1) ; rdpage() ; wtpage(1) )    /* write whole file */
  1172. X    ;
  1173. X    tvclr();
  1174. X  }
  1175. X#endif
  1176. X
  1177. X/* =============================>>> DWNCOL <<<============================= */
  1178. X  dwncol(cnt)
  1179. X  int cnt;
  1180. X  { /* dwncol - move down in column */
  1181. X
  1182. X    SLOW int curcol,l,oldef,needns;
  1183. X
  1184. X    needns = FALSE;
  1185. X    if (leftmg > 1)        /* handle right virtual screen different */
  1186. X      {
  1187. X    oldef=echof;
  1188. X    needns = TRUE;
  1189. X    echof = FALSE;
  1190. X      }
  1191. X
  1192. X    if (oldlex==VDOWNCOL || oldlex==VUPCOL)    /* several in a row? */
  1193. X    curcol=oldcol;        /* pick up old value */
  1194. X    else
  1195. X      {
  1196. X    curcol = curchr - *(lines+curlin);    /* calculate the current column */
  1197. X    oldcol = curcol;
  1198. X      }
  1199. X    dwnlin(cnt);        /* go down given lines */
  1200. X    if (curlin>=1 && curlin<nxtlin && curcol>1)    /* not at ends? */
  1201. X      {
  1202. X    l = strlen(buff + ((*(lines+curlin)) + 1) );
  1203. X    right(min(curcol-1,l));
  1204. X      }
  1205. X
  1206. X    if (needns)            /* needed new screen */
  1207. X      {
  1208. X    echof=oldef;
  1209. X    newscr();
  1210. X      }
  1211. X  }
  1212. X
  1213. X/* =============================>>> RMVLST <<<============================= */
  1214. X  int rmvlst()
  1215. X  {  /* rmvlst - delete the previous thing found or manipulated
  1216. X    length of oldlen is set by insert, find, and save
  1217. X    may also use savlen if set by save */
  1218. X
  1219. X    SLOW int oldech;
  1220. X#ifdef TVX_CMDSET
  1221. X    static int rmv_set[] =
  1222. X      {
  1223. X    VSEARCH, VNEXT, VSAVE, VGET, VSAGAIN, VSAPPEND,
  1224. X    VMVWORD, VMVBWORD, 0
  1225. X      };
  1226. X#endif
  1227. X#ifdef VI_EM
  1228. X    static int rmv_set[] =
  1229. X      {
  1230. X    VSEARCH, VSAVE, VGET, VSAGAIN, VSAPPEND, VPUT,
  1231. X    VMVWORD, VMVBWORD, VRSEARCH, VRSAGAIN, 0
  1232. X      };
  1233. X#endif
  1234. X#ifdef EMAX_EM
  1235. X    static int rmv_set[] =
  1236. X      {
  1237. X    VSEARCH, VNEXT, VSAVE, VGET, VSAGAIN, VSAPPEND,
  1238. X    VMVWORD, VMVBWORD, VRSEARCH, 0
  1239. X      };
  1240. X#endif
  1241. X
  1242. X    if (!inset(oldlex,rmv_set))
  1243. X    return (FALSE);
  1244. X
  1245. X    if (savlen > 0)
  1246. X      {
  1247. X    if (curlin == nxtlin-1 && slastl != 0)
  1248. X      {
  1249. X        --savlen;    /* reduce the count */
  1250. X        if (savlen > 0)
  1251. X          {
  1252. X        oldech = echof;
  1253. X        echof = FALSE;
  1254. X        killin(-savlen);    /* kill off previous lines */
  1255. X        echof = oldech;
  1256. X          }
  1257. X        killin(1);        /* kill the last line */
  1258. X      }
  1259. X    else
  1260. X        killin(-savlen);    /* kill off savlen lines */
  1261. X      }
  1262. X    else if (oldlen != 0)
  1263. X      {
  1264. X    if (! delnxt(-oldlen))
  1265. X        return (FALSE);
  1266. X      }
  1267. X    oldlen = 0;            /* don't allow multiple deletes! */
  1268. X    savlen = (-1);
  1269. X    return (TRUE);
  1270. X  }
  1271. X
  1272. X/* =============================>>> SAVE   <<<============================= */
  1273. X  int save(cnt,app)
  1274. X  int cnt,app;
  1275. X  { /* save - save cnt lines in save buffer */
  1276. X
  1277. X    SLOW int l,lend;
  1278. X    SLOW BUFFINDEX from;
  1279. X
  1280. X    if (curlin == nxtlin-1 && slastl!=0)
  1281. X      {
  1282. X    tverrb("Can't save last line twice! ");
  1283. X    return (FALSE);
  1284. X      }
  1285. X    if (cnt < 0)
  1286. X    return (FALSE);
  1287. X
  1288. X    oldlen = 0;            /* use savlin instead */
  1289. X
  1290. X    if ((oldlex != VSAVE && !app) || cnt == 0)
  1291. X      {             /* if new save, cnt == 0 and not appending */
  1292. X    slastl=0;
  1293. X    savlin=0;        /* haven't saved anything */
  1294. X    savlen=0;
  1295. X    nxtsav=mxbuff;    /* start saving at end */
  1296. X    if (cnt == 0)
  1297. X      {
  1298. X        return (TRUE);
  1299. X      }
  1300. X      }
  1301. X
  1302. X    if (oldlex != VSAPPEND && app)    /* need to reset count for append */
  1303. X    savlen=0;
  1304. X
  1305. X    lend=min(curlin+cnt-1 ,nxtlin-1);
  1306. X    for (l=curlin; l <= lend ; ++l)
  1307. X      {
  1308. X    if (nxtsav-nxtchr < ALMOSTOUT)    /* make space if need and can */
  1309. X        if (!gbgcol() || (nxtsav-nxtchr) < ALMOSTOUT)
  1310. X          {
  1311. X        tverrb("No save room ");
  1312. X        return (FALSE);
  1313. X          }
  1314. X
  1315. X    from = *(lines+l)+1;        /* first character of the line */
  1316. X    do
  1317. X      {
  1318. X        *(buff+nxtsav--) = *(buff+from++);
  1319. X      }
  1320. X    while (*(buff+from-1)!=ENDLINE);
  1321. X    ++savlin;        /* keep track of the length */
  1322. X    ++savlen;        /* savlen for rmvlst */
  1323. X    if (curlin==nxtlin-1)    /* don't save last line twice! */
  1324. X      {
  1325. X        slastl=1;
  1326. X        break;
  1327. X      }
  1328. X    dwnlin(1);    /* move to next line on screen for + only */
  1329. X      }
  1330. X#ifdef SCR_BUF
  1331. X    ttflush();
  1332. X#endif
  1333. X    return (TRUE);
  1334. X  }
  1335. SHAR_EOF
  1336. echo Extracting tvx_glbl.ic:
  1337. sed 's/^X//' >tvx_glbl.ic <<\SHAR_EOF
  1338. X/* ---------------   TVX global declarations   ------------------------ */
  1339. X
  1340. X/*   This version of TVX Copyright (c) 1986 by Bruce E. Wampler
  1341. X
  1342. X   Permission is hereby granted for free, unrestricted nonprofit
  1343. X   use of this software.  Please feel free to modify, distribute,
  1344. X   and share this software as long as you aren't making any money
  1345. X   from it.  If you want to use this code in a profit making environment,
  1346. X   please contact the author for permission.
  1347. X*/
  1348. X/*
  1349. X   Following trick allows only one file for externals.  If EXTERN is not
  1350. X   defined, then variables are decleared extern.  ONE module, tvlex.c,
  1351. X   defines EXTERN, and thus actually declares things.  If you need to
  1352. X   change one of these values (terminal definition, for example), then
  1353. X   only tvlex.c needs to be recompiled!
  1354. X*/
  1355. X#ifndef EXTERN
  1356. X#define EXTERN extern
  1357. X#define USEEXTERN /**/
  1358. X#endif
  1359. X
  1360. X/* constants defined within the next #ifndef area are the important
  1361. X   system values that define the terminal, margins, etc.  ALL variables
  1362. X   between begpatch and endpatch must be initialized for the MS-DOS cii-86
  1363. X   compiler to put them all in the same contiguous memory area.
  1364. X   This allows the tvconfig program to work properly to find the #####:
  1365. X   patch area patern.  This works on the C/80 CP/M version, too, but
  1366. X   has never been tried on unix since the termcap driver is normally used.
  1367. X*/
  1368. X
  1369. X#ifndef USEEXTERN
  1370. X    EXTERN char begpatch[6] = {'#','#','#','#','#',':'};
  1371. X
  1372. X#include "tvx_term.ic"        /* include terminal definitions */
  1373. X
  1374. X/* the order of lexsym values MUST be in the order specified here to
  1375. X   correspond to the order of the switch in edit()
  1376. X*/
  1377. X/* ---------------------------- Standard TVX --------------------------- */
  1378. X#ifdef TVX_EM            /* define standard command set */
  1379. X    EXTERN char lexsym[LEXVALUES+1] = { '@', 'r', 'l', 'd', 'u',
  1380. X      4, 21, 8, 'k', 'i', 11, '"', '\'', ',', '.', 'f', 6, 'p',
  1381. X      'b', 'e', 2, 'v', 'o', '/', 's', 'g', 23, 25, 24, ';', '&',
  1382. X      'm', ':', '=', 7, 9, '{', 'a', 16, '?', 'h', 20, 'c', 'j', 't',
  1383. X      'n', 14, 15, 5, 18, '#', '*','(', ')','~'};
  1384. X/*  SYNONYM and function key list */
  1385. X
  1386. X    EXTERN char loop_beg = '<';
  1387. X    EXTERN char loop_end = '>';
  1388. X
  1389. X    EXTERN char synofr[20] =    /* from table */
  1390. X      {' ',13,'[',']',000,000,000,000,000,000,00,00,00,00,00,00,00,00,00,00};
  1391. X    EXTERN char synoto[20] =        /* translate to table */
  1392. X      {'r','d','{','{',000,0,000,00,00,000,00,00,00,00,00,00,00,00,00,00};
  1393. X#ifdef IBMPC
  1394. X    EXTERN char funkey = 0;        /* leading char for function key */
  1395. X    EXTERN char funchar[50] =    /* code sent by function key */
  1396. X      {     /* make keypad function keys work like you would expect */
  1397. X     71,  72,  73,  75,  77,  79,  82,  83,  80,  81,
  1398. X     59, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1399. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1400. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1401. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1402. X      };
  1403. X    EXTERN char funcmd[50] =    /* equivalent command */
  1404. X      {
  1405. X    'b',  21, 'h', 'l', 'r', 'e', 'i',  11,   4, 'p',
  1406. X    '&', 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1407. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1408. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1409. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1410. X      };
  1411. X#else                /* regular terminal synonyms */
  1412. X    EXTERN char funkey = 0;        /* leading char for function key */
  1413. X    EXTERN char funchar[50] =    /* code sent by function key */
  1414. X      {
  1415. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1416. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1417. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1418. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1419. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000
  1420. X      };
  1421. X    EXTERN char funcmd[50] =    /* equivalent command */
  1422. X      {
  1423. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1424. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1425. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1426. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1427. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000
  1428. X      };
  1429. X#endif
  1430. X#endif        /* TVX_EM */
  1431. X
  1432. X/* ---------------------------- VI EMULATOR --------------------------- */
  1433. X#ifdef VI_EM            /* define vi emulation set */
  1434. X    EXTERN char lexsym[LEXVALUES+1] =
  1435. X      {
  1436. X      /*     1    2    3    4    5    6    7    8   9   10 */
  1437. X      '_',   2,   4,   6,   7,   8,  12, '=', '!', '#', '$',
  1438. X       '*', '/', ':', 'J', '?', '@', 'A', 'C', 'D', 'G',
  1439. X       'H', 'I',  14,  16, 'L', 'M', 'N', 'O', 'P', 'T',
  1440. X       'X', 'Y', 'Z', '^', 'a', 'b', 'c', 'd',  21, 'i',
  1441. X       '+', 'K', 'l', 'm', 'n', 'o', 'p', 'r', 's',  27,
  1442. X       'w', 'x', 'y', '~'
  1443. X      };
  1444. X    EXTERN char loop_beg = '<';
  1445. X    EXTERN char loop_end = '>';
  1446. X
  1447. X/*  SYNONYM and function key list */
  1448. X#ifdef VI_MODS            /* extended definitions */
  1449. X    EXTERN char synofr[20] =    /* from table */
  1450. X/*          ^J  ^M  ^R  ^T    */
  1451. X      { 'h',10, 13, 18, 20,' ','B','Q','W','`','q','z','j','k',
  1452. X    11,127,00,00,00,00};
  1453. X    EXTERN char synoto[20] =        /* translate to table */
  1454. X      {  8, 14,'+', 12,'T','l','b','T','w','M','T', 12,'+','K',
  1455. X    16,'X',00,00,00,00};
  1456. X#else                /* regular definitions */
  1457. X    EXTERN char synofr[20] =    /* from table */
  1458. X/*          ^J  ^M  ^R  ^T    */
  1459. X      { 'h',10, 13, 18, 20,' ','B','Q','W','`','q','z','j','k',
  1460. X    11,127,00,00,00,00};
  1461. X    EXTERN char synoto[20] =        /* translate to table */
  1462. X      {  8, 14,'+', 12,'T','l','b','T','w','M','T', 12, 14, 16,
  1463. X    16,'X',00,00,00,00};
  1464. X#endif
  1465. X
  1466. X#ifdef IBMPC
  1467. X    EXTERN char funkey = 0;        /* leading char for function key */
  1468. X    EXTERN char funchar[50] =    /* code sent by function key */
  1469. X      {     /* make keypad function keys work like you would expect */
  1470. X     71,  72,  73,  75,  77,  79,  82,  83,  80,  81,
  1471. X     00, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1472. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1473. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1474. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1475. X      };
  1476. X    EXTERN char funcmd[50] =    /* equivalent command */
  1477. X      {
  1478. X    'H', 'K',   2,   8, 'l', 'L', 'i', 'X', '+',   6,
  1479. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1480. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1481. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1482. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1483. X      };
  1484. X#else                /* regular terminal synonyms */
  1485. X    EXTERN char funkey = 0;        /* leading char for function key */
  1486. X    EXTERN char funchar[50] =    /* code sent by function key */
  1487. X      {
  1488. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1489. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1490. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1491. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1492. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000
  1493. X      };
  1494. X    EXTERN char funcmd[50] =    /* equivalent command */
  1495. X      {
  1496. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1497. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1498. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1499. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1500. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000
  1501. X      };
  1502. X#endif
  1503. X#endif
  1504. X/* .......................... MODELESS VERSIONS ........................ */
  1505. X/*
  1506. X    The lexical analyzer and parser has been designed to allow
  1507. X    function keys to be easily used for modeless commands.  The
  1508. X    best way is to define lexsym using the usual mnemonic forms
  1509. X    of commands, and use the function key and synonym tables to
  1510. X    define function keys.  First, map function keys to single
  1511. X    negative values (or chars with hi bit set (> 127)).  Then,
  1512. X    have those values mapped to the real command in the synomym
  1513. X    tables.
  1514. X*/
  1515. X/* ---------------------------- Modeless TVX --------------------------- */
  1516. X#ifdef TVX0M_EM
  1517. X   /* like tvx, except normal lower case commands map to ^X and normal
  1518. X      control commands map to ESC commands */
  1519. X    EXTERN char lexsym[LEXVALUES+1] = { '@', 18, 12, 4, 21,
  1520. X      'd', 'u', 8, 11, 'i', 'k', '"', '\'', ',', '.', 6, 'f', 16,
  1521. X        2, 5, 'b', 22, 15, '/', 's', 'g', 'w', 'y', 'x', ';', '&',
  1522. X      'm', ':', '=', 7, 9, '{', 'a', 'p', '?', 'h', 't', 3, 'j', 20,
  1523. X      14, 'n', 'o', 'e', 'r', '#', '*','(', ')','~'};
  1524. X/*  SYNONYM and function key list */
  1525. X
  1526. X    EXTERN char loop_beg = '<';
  1527. X    EXTERN char loop_end = '>';
  1528. X    EXTERN char synofr[20] =    /* from table */
  1529. X      {'[',']',0,0,000,000,000,000,000,000,00,00,00,00,00,00,00,00,00,00};
  1530. X    EXTERN char synoto[20] =        /* translate to table */
  1531. X      {'{','{',0,0,000,0,000,00,00,000,00,00,00,00,00,00,00,00,00,00};
  1532. X#ifdef IBMPC
  1533. X    EXTERN char funkey = 0;        /* leading char for function key */
  1534. X    EXTERN char funchar[50] =    /* code sent by function key */
  1535. X      {     /* make keypad function keys work like you would expect */
  1536. X     71,  72,  73,  75,  77,  79,  83,  80,  81, 000,
  1537. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1538. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1539. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1540. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1541. X      };
  1542. X    EXTERN char funcmd[50] =    /* equivalent command */
  1543. X      {
  1544. X      2,  21,  16,  12,  18,  5,   11,   4,  16, 000,
  1545. X        000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1546. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1547. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1548. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1549. X      };
  1550. X#else                /* regular terminal synonyms */
  1551. X    EXTERN char funkey = 0;        /* leading char for function key */
  1552. X    EXTERN char funchar[50] =    /* code sent by function key */
  1553. X      {
  1554. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1555. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1556. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1557. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1558. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000
  1559. X      };
  1560. X    EXTERN char funcmd[50] =    /* equivalent command */
  1561. X      {
  1562. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1563. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1564. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1565. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1566. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000
  1567. X      };
  1568. X#endif
  1569. X#endif
  1570. X
  1571. X/* ---------------------------- EMAX --------------------------- */
  1572. X#ifdef EMAX_EM
  1573. X   /* like tvx, except normal lower case commands map to ^X and normal
  1574. X      control commands map to ESC commands */
  1575. X    EXTERN char lexsym[LEXVALUES+1] =
  1576. X      { '%',   1,   2,   3,   4,   5,   6,   7,   8,  11,  12,
  1577. X          14,  15,  16,  18,  19,  22,  24,  25,  26, '!',
  1578. X             '#', '>', '<', 'b', 'f', 'v', '?'
  1579. X      };
  1580. X/*  SYNONYM and function key list */
  1581. X
  1582. X    EXTERN char loop_beg = '(';        /* <esc>( for emax */
  1583. X    EXTERN char loop_end = ')';
  1584. X
  1585. X    EXTERN char synofr[20] =    /* from table */
  1586. X      {127,0202,0203,0204,'s',000,000,000,000,000,00,00,00,00,00,00,00,00,00,00};
  1587. X    EXTERN char synoto[20] =        /* translate to table */
  1588. X      {  8, '<', 'v', '>', 19,0,000,00,00,000,00,00,00,00,00,00,00,00,00,00};
  1589. X#ifdef IBMPC
  1590. X    EXTERN char funkey = 0;        /* leading char for function key */
  1591. X    EXTERN char funchar[50] =    /* code sent by function key */
  1592. X      {     /* make keypad function keys work like you would expect */
  1593. X/*     hm,  ^,  pgu,  <-,  ->, end, del,  v , pgd, */
  1594. X     71,  72,  73,  75,  77,  79,  83,  80,  81, 000,
  1595. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1596. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1597. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1598. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1599. X      };
  1600. X    EXTERN char funcmd[50] =    /* equivalent command */
  1601. X      {
  1602. X    0202, 16,0203,   2,   6,0204,   4,  14,  22, 000,
  1603. X        000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1604. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1605. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1606. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1607. X      };
  1608. X#else                /* regular terminal synonyms */
  1609. X    EXTERN char funkey = 0;        /* leading char for function key */
  1610. X    EXTERN char funchar[50] =    /* code sent by function key */
  1611. X      {
  1612. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1613. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1614. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1615. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1616. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000
  1617. X      };
  1618. X    EXTERN char funcmd[50] =    /* equivalent command */
  1619. X      {
  1620. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1621. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1622. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1623. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
  1624. X    000, 000, 000, 000, 000, 000, 000, 000, 000, 000
  1625. X      };
  1626. X#endif
  1627. X#endif
  1628. X/* ------------------- END OF COMMAND SET VALUES ------------------ */
  1629. X
  1630. X    EXTERN char user_set[40] = "";        /* user search set */
  1631. X    EXTERN char use_wild = TRUE;        /* use wild cards by default */
  1632. X    EXTERN char old_cmds[16] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 };
  1633. X    EXTERN int old_cindex = 0;            /* cursor into old_cmds */
  1634. X    EXTERN int cut_mode = DEF_CUTMODE;        /* kill line cuts */
  1635. X#ifdef NOMODE_LEX
  1636. X    EXTERN int escape_chr = 27;            /* ESC is default prefix char */
  1637. X#else
  1638. X    EXTERN int escape_chr = 0;            /* ESC is default prefix char */
  1639. X#endif
  1640. X
  1641. X
  1642. X#ifdef MSDOS
  1643. X    EXTERN char cfgname[40] = "-c=\\bin\\config.tvx";
  1644. X#endif
  1645. X#ifdef GEMDOS
  1646. X    EXTERN char cfgname[40] = "-c=config.tvx";
  1647. X#endif
  1648. X#ifdef UNIX
  1649. X    EXTERN char cfgname[40] = "-c=config.tvx";
  1650. X#endif
  1651. X#ifdef OSCPM
  1652. X    EXTERN char cfgname[40] = "-c=a:config.tvx";
  1653. X#endif
  1654. X    EXTERN int endpatch = 0;    /* to get address of end of patch area */
  1655. X
  1656. X#else
  1657. X    EXTERN char begpatch[6];
  1658. X
  1659. X    EXTERN char lexsym[LEXVALUES+1];
  1660. X    EXTERN char loop_beg, loop_end;
  1661. X
  1662. X    EXTERN char synofr[20],    /* from table */
  1663. X    synoto[20];        /* translate to table */
  1664. X
  1665. X    EXTERN char funkey,        /* leading char for function key */
  1666. X    funchar[50],    /* code sent by function key */
  1667. X    funcmd[50];    /* equivalent command */
  1668. X    EXTERN int addx,        /* amount to add to get x */
  1669. X    addy;            /* to get y */
  1670. X    EXTERN char cxychr;        /* true if convert xy bin to ascii */
  1671. X    EXTERN char cversn[12],    /* a version to identify config */
  1672. X    cxy1st,            /* l if line first, c if column 1st */
  1673. X    cxybeg[8],        /* start xy control seq */
  1674. X    cxymid[8],        /* middle xy control seq */
  1675. X    cxyend[8],        /* end sequence */
  1676. X    cerrbg[8],        /* string to print when errors start */
  1677. X    cerred[8],        /* when errors done */
  1678. X    ctopb[8],        /* top blanks = reverse linefeed */
  1679. X    cinit[20],        /* start up sequence */
  1680. X    cendit[20],        /* to end session */
  1681. X    cbotb[8],        /* bottom sequence */
  1682. X    celin[8],        /* erase to end of line */
  1683. X    cescr[8],        /* erase to end of screen */
  1684. X    cclears[8],        /* clear and home */
  1685. X    cdelchr[8],        /* delete character */
  1686. X    ccsrcm[8],        /* set cursor to command mode */
  1687. X    ccsrin[8],        /* set cursor to insert mode */
  1688. X    ciline[8],        /* insert a line */
  1689. X    ckline[8],        /* kill a line */
  1690. X    cundlb[8],        /* turn on underline */
  1691. X    cundle[8],        /* turn off underline */
  1692. X    cboldb[8],        /* start bold */
  1693. X    cbolde[8];        /* end bold */
  1694. X
  1695. X    EXTERN int dsp_mem,ddline,dscrl,dxcase,usecz,autoin,logdef;
  1696. X    EXTERN char delkey;
  1697. X
  1698. X    EXTERN int    tvlins,    /* number of lines on screen */
  1699. X        tvcols,    /* number of columns on screen */
  1700. X        tvhardlines,    /* real number of lines (for small window) */
  1701. X        tvx,    /* current x cursor position */
  1702. X        tvy,    /* current y cursor position */
  1703. X        tvdlin,    /* the "active" display line */
  1704. X        dsplin,    /* the default display line */
  1705. X        tabspc,    /* spacing for tabs */
  1706. X        leftmg,    /* left margin of display */
  1707. X        wraplm,    /* auto wrap? */
  1708. X        isibmpc; /* for possible use with a general version */
  1709. X
  1710. X    EXTERN char user_set[40],            /* wild matches */
  1711. X    use_wild;
  1712. X
  1713. X    EXTERN char old_cmds[16];
  1714. X    EXTERN int old_cindex;            /* cursor into old_cmds */
  1715. X    EXTERN int cut_mode;            /* kill line cuts */
  1716. X    EXTERN int escape_chr;            /* prefix char */
  1717. X
  1718. X    EXTERN char cfgname[40];
  1719. X
  1720. X    EXTERN int endpatch;    /* to get address of end of patch area */
  1721. X#endif
  1722. X
  1723. X
  1724. X    EXTERN int    bakpos,        /* used when building log file */
  1725. X        bakflg,        /* if writing to log file */
  1726. X        usebak,        /* if want to build a log file or not */
  1727. X        makebackup;    /* if want to retain backup .bak file */
  1728. X
  1729. X    EXTERN BUFFINDEX nxtsav,    /* top of save buffer */
  1730. X        curchr,        /* pointer to current character */
  1731. X        nxtchr,        /* ptr to buff of next new chr */
  1732. X        mxbuff,        /* maximum number of chars in buff */
  1733. X        *lines;        /* line ptrs */
  1734. X
  1735. X    EXTERN int     curlin,        /* pointer to current line */
  1736. X        nxtlin,        /* ptr to lines of next new line */
  1737. X        mxline;        /* maximum number of lines */
  1738. X
  1739. X    EXTERN char *buff;        /* character and save buffer */
  1740. X
  1741. X#ifdef NOALLOC
  1742. X    EXTERN int myline[MAXLINE+1];    /* the real line buffer */
  1743. X    EXTERN char mybuff[MAXBUFF+1];    /* the real buffer */
  1744. X#endif
  1745. X
  1746. X    EXTERN int    oldlen,        /* length for '=' command */
  1747. X        savlin,        /* number of saved lines */
  1748. X        savlen;        /* line lenght of save buffer for rmvlst */
  1749. X
  1750. X    EXTERN int    oldlex,        /* last commands lexical value */
  1751. X        oldcol,        /* beginning column for dwncol */
  1752. X        echof,        /* whether or not to echo action */
  1753. X        xcases,        /* exact case flag */
  1754. X        scroll;        /* scroll window */
  1755. X
  1756. X    EXTERN int newfil;        /* YES if creating a new file */
  1757. X    EXTERN int rdonly;        /* YES if reading a file only */
  1758. X
  1759. X    EXTERN char orig_file[FNAMESIZE+1],    /* original file */
  1760. X        source_file[FNAMESIZE+1], /* where file really is */
  1761. X        work_file[FNAMESIZE+1],    /* current working output file */
  1762. X        dest_file[FNAMESIZE+1];    /* ultimate name for file */
  1763. X
  1764. X    EXTERN int    rptuse,            /* which repeat buffer currently active */
  1765. X        rptcnt[REPEATBUFS],    /* number of repeats left to do */
  1766. X        nxtrpt[REPEATBUFS];    /* pointer to next repeat character */
  1767. X
  1768. X    EXTERN char rptbuf[REPEATBUFS][102]; /* up to 100 chars in repeat loop */
  1769. X    EXTERN char sbuff[102];        /* search buffer */
  1770. X    EXTERN char pat_buff[102];        /* save the pattern */
  1771. X
  1772. X/* other globals */
  1773. X#ifndef USEEXTERN
  1774. X    int slastl = 0;
  1775. X#else
  1776. X    extern int slastl;
  1777. X#endif
  1778. X
  1779. X    EXTERN char unkbuf[130];
  1780. X
  1781. X    EXTERN int useprint;    /* whether to print */
  1782. X    EXTERN int xoutcm;        /* used for 240 col virtual screen */
  1783. X    EXTERN int last_col_out;    /* last column output */
  1784. X    EXTERN int waserr;
  1785. X    EXTERN int blimit;        /* limit for read in buffer */
  1786. X    EXTERN int ttymode;        /* true if in tty mode */
  1787. X    EXTERN int ttynext;        /* cursor to next char from rdtty */
  1788. X    EXTERN int ins_mode;    /* true if insert mode */
  1789. X    EXTERN int force_tty;    /* for unix to force tty mode */
  1790. X
  1791. X
  1792. X    EXTERN FILE *infile, *outfile, *bkuin, *bkuout;
  1793. X    EXTERN int ineof;
  1794. X
  1795. X/* ---------------------------- GLOBALS ------------------------------- */
  1796. SHAR_EOF
  1797. echo ALL DONE!
  1798. exit 0
  1799.  
  1800.